package io.github.wppli.domain.recommond.model.valobj;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author li--jiaqiang 2025−03−12
 */
@Getter
@AllArgsConstructor
public enum UserProductBehaviorType {

    // 浏览
    VIEW(1.0f, "view"),
    // 收藏
    COLLECT(2.0f, "collect"),
    // 加入购物车
    ADD_TO_CART(3.0f, "add_to_cart"),
    // 下单
    BUY(4.0f, "buy"),
    ;

    private final float weight;
    private final String value;

    public static UserProductBehaviorType fromValue(String value) {
        for (UserProductBehaviorType type : values()) {
            if (type.getValue().equals(value)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Invalid UserBehaviorType value: " + value);
    }
}